package com.nantong.common.core.enums.commonEnums;

import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 客户来源枚举
 *
 * @author nantong
 */
@Getter
@AllArgsConstructor
public enum CustomerSourceEnum {
    OFFICIAL_WEBSITE(1, "官网"),
    RECOMMENDATION(2, "推荐"),
    EXHIBITION(3, "展会");

    @JsonValue
    private final Integer code;
    private final String desc;

    public static CustomerSourceEnum fromCode(Integer code) {
        for (CustomerSourceEnum value : CustomerSourceEnum.values()) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        return null;
    }
}